package com.dindang.propertyfee.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.constraint.Group;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import com.dindang.propertyfee.di.component.DaggerQrCodeCollectionComponent;
import com.dindang.propertyfee.di.module.QrCodeCollectionModule;
import com.dindang.propertyfee.mvp.contract.QrCodeCollectionContract;
import com.dindang.propertyfee.mvp.presenter.QrCodeCollectionPresenter;

import com.dindang.propertyfee.R;


import static com.jess.arms.utils.Preconditions.checkNotNull;

@Route(path = "/propertyfee/activity/QrCodeCollectionActivity")
public class QrCodeCollectionActivity extends BaseActivity<QrCodeCollectionPresenter> implements QrCodeCollectionContract.View {

    ImageView mIvBack;
    TextView mTvTitle;
    ImageView mIvQrCode;
    TextView mTvCancle;
    Group mGroupQrCode;

    TextView mTvPrint;
    TextView mTvBack;
    TextView mTvTotalPrice;
    TextView mTvAutoJump;
    Group mGroupSuccess;

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerQrCodeCollectionComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .qrCodeCollectionModule(new QrCodeCollectionModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.propertyfee_activity_qr_code_collection; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mIvBack = findViewById(R.id.propertyfee_iv_back);
        mTvTitle = findViewById(R.id.propertyfee_tv_title);
        mIvQrCode = findViewById(R.id.propertyfee_iv_qr_code);
        mTvCancle = findViewById(R.id.propertyfee_tv_cancle);
        mGroupQrCode = findViewById(R.id.propertyfee_group_qr_code);

        mTvPrint = findViewById(R.id.propertyfee_tv_print);
        mTvBack = findViewById(R.id.propertyfee_tv_back);
        mTvTotalPrice = findViewById(R.id.propertyfee_tv_total_price);
        mTvAutoJump = findViewById(R.id.propertyfee_tv_auto_jump);
        mGroupSuccess = findViewById(R.id.propertyfee_group_success);

        mTvTitle.setText("二维码支付");
        mIvBack.setOnClickListener(v -> finish());
        mTvCancle.setOnClickListener(v -> finish());
        mTvBack.setOnClickListener(v -> finish());
        mPresenter.init();
    }



    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public TextView getTvTitle() {
        return mTvTitle;
    }

    @Override
    public ImageView getIvQrCode() {
        return mIvQrCode;
    }

    @Override
    public Group getGroupQrCode() {
        return mGroupQrCode;
    }

    @Override
    public TextView getTvPrint() {
        return mTvPrint;
    }

    @Override
    public TextView getTvTotalPrice() {
        return mTvTotalPrice;
    }

    @Override
    public TextView getTvAutoJump() {
        return mTvAutoJump;
    }

    @Override
    public Group getGroupSuccess() {
        return mGroupSuccess;
    }

    @Override
    public BaseActivity getActivity() {
        return this;
    }
}
